import { useIntersectionObserver } from '@vueuse/core'
export const lazy_load_img = { 
  install (app) {
    app.directive('lazy-load-img', {
   mounted(el, binding) {
    //el :指令绑定的那个元素
    //binding: binding.value 
    // console.log(el, binding.value);
    const {stop} = useIntersectionObserver(
    el,
     ([entry]) => {
      // console.log(entry.isIntersecting);
      //进入视口区域
      if (entry.isIntersecting) {
        el.src = binding.value
        stop()//关闭持续侦听，减少性能消耗
      }
    },
  )
   },
  /* ... */
})
  }
}